package com.starblink.android.common.view.badgeview;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * 支持角标的LinearLayout
 */
public class BGABadgeLinearLayout extends LinearLayout implements BGABadgeable {
  private BGABadgeViewHelper mBadgeViewHelper;

  public BGABadgeLinearLayout(Context context) {
    this(context, null);
  }

  public BGABadgeLinearLayout(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
  }

  public BGABadgeLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mBadgeViewHelper = new BGABadgeViewHelper(this, context, attrs, BGABadgeViewHelper.BadgeGravity.RightTop);
  }

  @Override
  public boolean onTouchEvent(MotionEvent event) {
    return mBadgeViewHelper.onTouchEvent(event);
  }

  @Override
  public boolean callSuperOnTouchEvent(MotionEvent event) {
    return super.onTouchEvent(event);
  }

  @Override
  public void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    mBadgeViewHelper.drawBadge(canvas);
  }

  @Override
  public void showCirclePointBadge() {
    mBadgeViewHelper.showCirclePointBadge();
  }

  @Override
  public void showTextBadge(String badgeText) {
    mBadgeViewHelper.showTextBadge(badgeText);
  }

  @Override
  public void hiddenBadge() {
    mBadgeViewHelper.hiddenBadge();
  }

  @Override
  public void showDrawableBadge(Bitmap bitmap) {
    mBadgeViewHelper.showDrawable(bitmap);
  }

  @Override
  public void setDragDismissDelegate(BGADragDismissDelegate delegate) {
    mBadgeViewHelper.setDragDismissDelegate(delegate);
  }

  @Override
  public boolean isShowBadge() {
    return mBadgeViewHelper.isShowBadge();
  }

  @Override
  public boolean isDraggable() {
    return mBadgeViewHelper.isDraggable();
  }

  @Override
  public boolean isDragging() {
    return mBadgeViewHelper.isDragging();
  }

  @Override
  public BGABadgeViewHelper getBadgeViewHelper() {
    return mBadgeViewHelper;
  }
}
